package org.lhh.server.core.repository;

import org.pentaho.di.cluster.ClusterSchema;
import org.pentaho.di.cluster.SlaveServer;
import org.pentaho.di.core.CheckResultInterface;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.repository.*;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.metastore.stores.delegate.DelegatingMetaStore;

import java.util.ArrayList;
import java.util.List;

public interface EtlService {

    UserInfo getUserInfo(String username, EtlKettleDatabaseRepository repository);

    TransMeta getTransMeta(String transName, ObjectId objectId, EtlKettleDatabaseRepository repository);

    List<TransMeta> getTransMetas(ObjectId objectId, EtlKettleDatabaseRepository repository);

    void saveTrans(TransMeta transMeta, EtlKettleDatabaseRepository repository);

    void deleteTrans(String transName, ObjectId pId, EtlKettleDatabaseRepository repository);

    RepositoryDirectoryInterface getHomeDirectory(EtlKettleDatabaseRepository repository);

    void tranMetaCheckSteps(ArrayList<CheckResultInterface> checkResultInterfaces
            , boolean selected
            , TransMeta transMeta
            , DelegatingMetaStore metaStore
            , EtlKettleDatabaseRepository repository);

    void saveClusterSchema(ClusterSchema clusterSchema, EtlKettleDatabaseRepository repository);

    void delClusterSchema(long id, EtlKettleDatabaseRepository repository);

    List<SlaveServer> getSlaveServers(EtlKettleDatabaseRepository repository);

    ObjectId[] getClusterIDs(boolean includeDeleted, EtlKettleDatabaseRepository repository);

    ClusterSchema loadClusterSchema(ObjectId objectId, List<SlaveServer> allServers, EtlKettleDatabaseRepository repository);

    TransMeta loadTransformation(ObjectId transformationID, EtlKettleDatabaseRepository repository);

    void saveDatabaseMeta(DatabaseMeta databaseMeta, EtlKettleDatabaseRepository repository);

    DatabaseMeta loadDatabaseMeta(ObjectId objectId, EtlKettleDatabaseRepository repository);

    DatabaseMeta loadDatabaseMeta(String connection, EtlKettleDatabaseRepository repository);

    List<DatabaseMeta> readDatabases(EtlKettleDatabaseRepository repository);

    void deleteDatabaseMeta(String name, EtlKettleDatabaseRepository repository);

    void saveSlaveServer(SlaveServer slaveServer, EtlKettleDatabaseRepository repository);

    void deleteSlave(ObjectId objectId, EtlKettleDatabaseRepository repository);

    RepositoryDirectoryInterface directoryTree(EtlKettleDatabaseRepository repository);

    RepositoryDirectoryInterface getDirectory(ObjectId objectId, EtlKettleDatabaseRepository repository);

    boolean existDirectory(String name, ObjectId id, ObjectId pId, EtlKettleDatabaseRepository repository);

    void saveDirectory(RepositoryDirectory repositoryDirectory, EtlKettleDatabaseRepository repository);

    void renameDirectory(String name, ObjectId id, ObjectId pId, EtlKettleDatabaseRepository repository);

    void removeDirectory(ObjectId id, EtlKettleDatabaseRepository repository);

    void moveDirectory(ObjectId id, ObjectId pId, EtlKettleDatabaseRepository repository);

    List<RepositoryElementMetaInterface> getTransformationObjects(LongObjectId objectId, EtlKettleDatabaseRepository repository);

    boolean existTransMeta(String name, ObjectId id, ObjectId pId, EtlKettleDatabaseRepository repository);
}
